package com.gykfbxxh.imovie.bean.news;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.app.utils.util.DateUtils;
import com.app.utils.util.view.image.CircleImageView;
import com.gykfbxxh.imovie.R;
import com.gykfbxxh.imovie.bean.film.FilmListEntity;
import com.gykfbxxh.imovie.utils.glide.ImageLoader;


/**
 * 新闻列表的视频有边
 * Created by xuxinghai on 2016/7/17.
 */
public class ViewNotice  {


    public CircleImageView civ_usericon;
    public TextView tv_username;
    public TextView tv_time;
    public TextView tv_title;




    public ViewNotice(View convertView) {
        initView(convertView);
    }

    /**
     * 初始化控件
     * @param convertView
     */
    public void initView(View convertView) {
        tv_title = (TextView) convertView.findViewById(R.id.tv_title);
        civ_usericon = (CircleImageView) convertView.findViewById(R.id.civ_usericon);
        tv_username = (TextView) convertView.findViewById(R.id.tv_username);
        tv_time = (TextView) convertView.findViewById(R.id.tv_time);
        convertView.setTag(this);
    }

    /**
     * 加载数据
     * @param listBean
     */
    public void loadData(Context context, FilmListEntity listBean){
        tv_time.setText(DateUtils.getStrTime_mdhm(DateUtils.getTime(listBean.getFIntime())));
        if("0".equals(listBean.getfType())) {
            tv_title.setText(listBean.getFObject().getFKeyword());
            ImageLoader.getInstance().listLoadImage2Cache(context,civ_usericon,listBean.getFObject().getFPhotos());
            try {
                tv_username.setText(listBean.getFObject().getFName());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else if("1".equals(listBean.getfType())) {
            tv_username.setText("系统通知");
            tv_title.setText(listBean.getfBody());
            civ_usericon.setImageResource(R.drawable.tongzhi);
        }
    }

}
